<template>
  <div>
    <div class="msg">
      <div class="msg-show">
        <div class="msg-left">
          <div class="left-img"></div>
          <div class="left-detail">
            <h2>订单提交成功！去付款咯～</h2>
            <h3>0小时30分内完成支付, 超时后将取消订单</h3>
            <h3>收货信息:{{ addresInfo }}</h3>
          </div>
        </div>
        <div class="msg-right">
          <div>应付总额:{{ totalPrice }}</div>
          <div>订单详情<i class="icon" @click="changDetail">0</i></div>
        </div>
      </div>
      <div class="msg-detail" v-show="showDetail">
        <div>订单号:{{ orderId }}</div>
        <div>收货信息:{{ addresInfo }}</div>
        <div>
          商品信息:
          <div v-for="(item, index) in goods_infos" :key="index">
            {{ item.productName }} {{ item.productDesc }}
          </div>
        </div>
        <div>发票信息:电子发票</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getsingleOrder } from "../assets/request";

export default {
  data() {
    return {
      showDetail: false,
      addresInfo: "",
      totalPrice: "",
      orderId: "",
      goods_infos: [],
    };
  },
  async created() {
    let res = await getsingleOrder(this.$route.query.id);
    let item = res.s_address;
    this.totalPrice = res.total_price;
    this.orderId = res.order_id;
    this.addresInfo = `${item.name} ${item.phone} ${item.area_name} ${item.desc}`;
    // 获取单条订单的详细信息 并渲染
    // console.log(res);
    this.goods_infos = res.goods_info.map((ele) => {
      return {
        prdoctImage: ele.s_goods_photos[0].path,
        productName: ele.goods_name,
        productDesc: ele.desc,
      };
    });
  },
  methods: {
    changDetail() {
      this.showDetail = !this.showDetail;
    },
  },
};
</script>

<style lang="scss" scoped>
.msg {
  width: 1226px;
  margin: 0 auto;
  .msg-show {
    width: 100%;
    padding: 10px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: skyblue;
  }
  .msg-detail {
    width: 100%;
    margin: 0 auto;
    background: pink;
    padding: 10px;
  }
}
</style>